package com.myproject.controller;

import com.myproject.timer.MyTimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Timer;

@RestController
public class TimerController {

    private static final Logger logger = LoggerFactory.getLogger(TimerController.class);
    public static Thread currThread;

    @GetMapping("/start")
    public String method(){

        Timer timer = new Timer();
        timer.schedule(new MyTimerTask(),0,5000);

        return "ok";
    }

    @GetMapping("/getState")
    public String method1(){

        return currThread.getState().toString();
    }





}
